package com.tao.controller;

import com.tao.mapper.CategoryMapper;
import com.tao.pojo.entity.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CategoryController {
    @Autowired
    CategoryMapper categoryMapper;
    @RequestMapping("/category/select")
    public List<Category> select(){
       return categoryMapper.select();
    }
    @RequestMapping("/category/delete")
    public void deleteById(int id){
        categoryMapper.deleteById(id);
    }
    @RequestMapping("/category/insert")
    public List<Category> insert(String name){
        categoryMapper.insert(name);
        return categoryMapper.select();
    }
    @RequestMapping("/category/update")
    public void update(@RequestBody Category category){
        categoryMapper.update(category);
    }
}
